import request from '@/utils/request'

// 获取个人信息
export function getProfile() {
  return request({
    url: '/api/profile/info',
    method: 'get'
  })
}

// 更新个人信息
export function updateProfile(data) {
  return request({
    url: '/api/profile/update',
    method: 'put',
    data
  })
}

// 修改密码
export function changePassword(data) {
  return request({
    url: '/api/profile/password',
    method: 'put',
    data
  })
}

// 更新头像
export function updateAvatar(data) {
  return request({
    url: '/api/profile/avatar',
    method: 'put',
    data
  })
}

// 上传头像
export function uploadAvatar(file) {
  const formData = new FormData()
  formData.append('file', file)

  return request({
    url: '/upload/avatar',
    method: 'post',
    data: formData,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  })
}

// 上传课程封面
export function uploadCourseCover(file) {
  const formData = new FormData()
  formData.append('file', file)

  return request({
    url: '/upload/course-cover',
    method: 'post',
    data: formData,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  })
}

// 上传教师头像
export function uploadTeacherAvatar(file) {
  const formData = new FormData()
  formData.append('file', file)

  return request({
    url: '/upload/teacher-avatar',
    method: 'post',
    data: formData,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  })
}

// 上传教师证书
export function uploadTeacherCertificate(file) {
  const formData = new FormData()
  formData.append('file', file)

  return request({
    url: '/api/upload/teacher-certificate',
    method: 'post',
    data: formData,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  })
}
